#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

class Solution {
    public:
        string countAndSay(int n) {
            string ans = "1";
            for (int i = 2; i <= n; i++) {
                //cout << ans << endl;
                string cur;
                char pre = ans[0];
                int count = 1;
                for (int i = 1; i < ans.size(); i++) {
                    if (ans[i] != pre) {
                        cur += count + '0';
                        cur += pre;
                        pre = ans[i];
                        count = 1;    
                    } else {
                        count++;
                    }
                }
                cur += count + '0';
                cur += pre;
                ans = cur;
            }
            return ans;
        }
};

//test on 1337 online judge and pass all the test
int main(int argc, char **argv)
{
    Solution mySolution;

    cout << "-----------------Test 1--------------------" << endl;
    mySolution.countAndSay(6);


    cout << "-----------------Test 2--------------------" << endl;


    cout << "-----------------Test 3--------------------" << endl;


    cout << "-----------------Test 4--------------------" << endl;


    cout << "-----------------Test 5--------------------" << endl;



}
